struct Solution {}

fn main() {}

impl Solution {
    pub fn find_max_average(nums: Vec<i32>, k: i32) -> f64 {
        let mut max: i32 = 0;
        let mut max_sum: i32 = i32::MIN;
        let uk = k as usize;

        for idx in 0..=nums.len() - uk {
            let cur_sum = nums[idx..idx + uk].iter().sum();
            if cur_sum > max_sum {
                max = idx as i32;
                max_sum = cur_sum;
            }
        }
        max_sum as f64 / k as f64
    }
}